from django.db import models
from reference import Reference, Algorithm
from simcat.datatypes import CARDINALITY_OPTIONS, DATATYPE_OPTIONS

class Program(models.Model):
    name = models.SlugField(unique=True)
    url = models.URLField(null=True, blank=True)
    description = models.TextField(null=True, blank=True)
    references = models.ManyToManyField(Reference, null=True, blank=True)
    algorithm = models.ManyToManyField(Algorithm, null=True, blank=True)
    
    class Admin:
        pass

    class Meta:
     	app_label = "simcat"

    def __unicode__(self):
        return self.name

class Parameter(models.Model):
    program = models.ForeignKey(Program)
    name = models.CharField(max_length=128)
    datatype = models.CharField(max_length=16, choices=DATATYPE_OPTIONS)
    cardinality = models.CharField(max_length=16, choices=CARDINALITY_OPTIONS)
    url = models.URLField(null=True, blank=True)
    description = models.TextField(null=True, blank=True)
    references = models.ManyToManyField(Reference, null=True, blank=True)
    units = models.CharField(max_length=128, null=True, blank=True)
    ucd = models.CharField(max_length=128, null=True, blank=True)

    class Admin:
        pass

    class Meta:
	app_label = "simcat"

    def __unicode__(self):
        return self.name
